#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
//#include <QTimer>
//#include <QtNetwork>
//#include <QAbstractSocket>
#include <QTcpSocket>


namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::MainWindow *ui;

private slots:
    void on_pushButton_6_clicked();
    void on_pushButton_clicked();
    void on_pushButton_4_clicked();
    void on_pushButton_2_clicked();
    void on_pushButton_3_clicked();
    void on_readPkg();

// slots:

    void on_writePkg(int type, char *msg, int len);
    void on_msgRecv(int type, char *msg);
    void connectOK();
    void disconnectOK();

////////////////////////////////////////////////////////

signals:
    void dispach_message(int type, char *msg);
    void writePkg(int type, char *msg, int len);

private:
    QTcpSocket *mTcpSocket;
    int isConnected;

    void on_groupListReply(int type, char *msg);
    void on_groupCreateReply(int type, char *msg);
    void on_userJoinReply(int type, char *msg);

public:

    long userid;
    long groupid;

    void on_userReceive(int type, char *msg);
    void on_userListReply(int type, char *msg);
    void getUserList();

};

#endif // MAINWINDOW_H
